<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function datas() {
            return{
                msg:'aa',
                num:'2'
            }
        }
        var obj1 = datas();//此处是函数返回
        var obj2 = datas();
        obj2.msg = 'bbb';
        console.log(obj1)//{msg: "aa", num: "2"}
        console.log(obj2)//{msg: "bbb", num: "2"}
        console.log('---------------------')
        var msg1 = {
            msg:'aa',
        }
        function datas1(){
            return msg1;
        }
        var a = datas1();//此次是对象返回,a改变msg后,影响到b
        var b = datas1();
        
        a.msg="abc"
        console.log(a)//{msg: "abc"}
        console.log(b)//{msg: "abc"}
    </script>   
    
</body>
</html>